import 'package:flutter/material.dart';

class ContentContainer extends StatelessWidget {
  final Widget? contentWidget;
  final Widget? bottomWidget;
  final bool isScrollable;
  final Clip? childClipBehavior;

  const ContentContainer(
      {Key? key,
      this.contentWidget,
      this.bottomWidget,
      this.isScrollable = true,
      this.childClipBehavior})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return LayoutBuilder(
        builder: (BuildContext context, BoxConstraints boxConstraint) {
      return SingleChildScrollView(
        physics: isScrollable ? null : NeverScrollableScrollPhysics(),
        child: ConstrainedBox(
          constraints: boxConstraint.copyWith(
            minHeight: boxConstraint.minHeight,
            maxHeight: boxConstraint.maxHeight,
          ),
          child: IntrinsicHeight(
            child: Column(
              children: [
                if (contentWidget != null)
                  Expanded(
                    child: contentWidget!,
                  )
                else
                  Spacer(),
                if (bottomWidget != null) bottomWidget!,
              ],
            ),
          ),
        ),
      );
    });
  }
}
